package cc.admin.modules.sys.service.impl;

import cc.admin.common.sys.vo.LoginUser;
import cc.admin.modules.sys.entity.SysCompany;
import cc.admin.modules.sys.entity.SysSubsystem;
import cc.admin.modules.sys.mapper.SysSubsystemMapper;
import cc.admin.modules.sys.service.ISysSubsystemService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * \n
 *
 * @author zxy
 * @date 2022-07-07 9:26
 * @description description\n
 */
@Service
public class SysSubsystemServiceImpl extends ServiceImpl<SysSubsystemMapper, SysSubsystem> implements ISysSubsystemService {

    @Autowired
    SysSubsystemMapper sysSubsystemMapper;


    @Override
    public List<Map<String, String>> getSubSystemName() {
        QueryWrapper queryWrapper = new QueryWrapper();
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        List<SysSubsystem> subsystems = sysSubsystemMapper.selectList(queryWrapper);
        List<Map<String, String>> dataList = Lists.newArrayList();
        for (SysSubsystem subsystem : subsystems) {
            Map<String, String> map = Maps.newHashMap();
            map.put("label", subsystem.getName());
            map.put("value", subsystem.getCode());
            dataList.add(map);
        }
        return dataList;
    }
}
